import {
	api
} from '@/common/utils/request.js';
import {
	toPageParam,
	toPageResult
} from '@/common/services/index.js'
import env from '../utils/env.js'
const clientUuid = require('uuid');

/* 查询列表 */
export function houseList(data) {
	return api({
		url: "/house/page",
		data: toPageParam(data),
		method: "post"
	}).then(ret => {
		return ret.data;
	});
}


/* 查询历史表格 */
export function pageHistory(data) {
	return api({
		url: "/house/page/history",
		data: toPageParam(data),
		method: "post"
	}).then(ret => {
		return ret.data;
	});
}


/* 确认提交 */
export function confirm(batchNo, type) {
	return api({
		url: `/house/confirm/${batchNo}/${type}`,
		data: {},
		method: "get"
	}).then(ret => {
		return ret.data;
	});
}

/* 所属街道 */
export function getStreetNameDropDownList() {
	return api({
		url: `/house/getStreetNameDropDownList`,
		data: {},
		method: "get"
	}).then(ret => {
		return ret.data;
	});
}
/* 删除上传历史记录 */
export function deleteHistoryById(id) {
	return api({
		url: `/house/deleteHistoryById/${id}`,
		data: {},
		method: "get"
	}).then(ret => {
		return ret.data;
	});
}
/* 删除房源 */
export function deleteById(id, type) {
	return api({
		url: `/house/deleteById/${id}/${type}`,
		data: {},
		method: "get"
	}).then(ret => {
		return ret.data;
	});
}
/* 首页统计 */
export function getSummary(){
	return api({
		url: `/house/getSummary`,
		data: {},
		method: "get"
	}).then(ret => {
		return ret.data;
	});
}

/* 确认上传附件 */
export function confirmUploadAttachment(data) {
	return api({
		url: `/house/confirmUploadAttachment`,
		data: data,
		method: "post"
	}).then(ret => {
		return ret.data;
	});
}

/* 删除安置房附件 */
export function deleteAttachment(id, type) {
	return api({
		url: `/house/deleteAttachment/${type}/${id}`,
		data: {},
		method: "get"
	});
}

/* 获取房屋总览房型性质 */
export function getProjectHouseNameList(id, type) {
	return api({
		url: `/house/getProjectHouseNameList`,
		data: {},
		method: "get"
	}).then(ret => {
		return ret.data;
	});
}

/* 创建下载任务 */
export function createDownLoadTask(data) {
	return api({
		url: `/house/createDownLoadTask/${clientUuid.v4()}`,
		data: data,
		method: "post"
	}).then(ret => {
		return ret.data;
	});
}


/* 下载 */
export function downLoadExcel(id) {
	window.open(`${env.base}/export/downLoad/${id}?access_token=` + uni.getStorageSync("atoken") || '', "_blank");
}

/* 导出上传记录 */
export function downLoadExcelBatch(key) {
	window.open(`${env.base}/export/downLoad/excel/${key}?access_token=` + uni.getStorageSync("atoken") || '', "_blank");
}

/* 导出房源数据 */
export function downLoadExcelBatchByType(key, type) {
	window.open(`${env.base}/export/downLoad/excel/${key}/${type}?access_token=` + uni.getStorageSync("atoken") || '', "_blank");
}

